package com.fastloan.core.apiauth.base.endecrypt.impl;

import com.fastloan.core.apiauth.base.endecrypt.EnDecrypt;
import com.fastloan.core.apiauth.base.util.AesUtil;

/**
 * AES/CBC/
 *
 * @author yanwe
 * createTime 2018-01-2018/1/3 14:35
 */
public class AesCBC implements EnDecrypt {

    private String key;

    private String iv;

    public AesCBC(String key, String iv) {
        this.key = key;
        this.iv = iv;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getIv() {
        return iv;
    }

    public void setIv(String iv) {
        this.iv = iv;
    }

    @Override
    public String encrypt(String data) {
        return AesUtil.encryptByCBC(data,key,iv);
    }

    @Override
    public String decrypt(String data) {
        return AesUtil.decryptByCBC(data,key,iv);
    }
}
